<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>MiXiM: FindModule&lt; T &gt; Class Template Reference</title>

<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>


</head>
<body>
<div id="top"><!-- do not remove this div! -->


<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  
  
  <td style="padding-left: 0.5em;">
   <div id="projectname">MiXiM
   &#160;<span id="projectnumber">2.3</span>
   </div>
   
  </td>
  
  
  
 </tr>
 </tbody>
</table>
</div>

<!-- Generated by Doxygen 1.7.5.1 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li class="current"><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
      <li><a href="dirs.html"><span>Directories</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="annotated.html"><span>Class&#160;List</span></a></li>
      <li><a href="classes.html"><span>Class&#160;Index</span></a></li>
      <li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
      <li><a href="functions.html"><span>Class&#160;Members</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('a00093.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="summary">
<a href="#pub-static-methods">Static Public Member Functions</a>  </div>
  <div class="headertitle">
<div class="title">FindModule&lt; T &gt; Class Template Reference<div class="ingroups"><a class="el" href="a00518.html">baseUtils - utilities for base MiXiM</a> &#124; <a class="el" href="a00514.html">utils  -  utility classes</a></div></div>  </div>
</div>
<div class="contents">
<!-- doxytag: class="FindModule" -->
<p>Provides method templates to find omnet modules.  
 <a href="a00093.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="a00306_source.html">FindModule.h</a>&gt;</code></p>

<p><a href="a00750.html">List of all members.</a></p>
<table class="memberdecls">
<tr><td colspan="2"><h2><a name="pub-static-methods"></a>
Static Public Member Functions</h2></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00093.html#a661c335281d62d8df4affc46cc4fff9f">findSubModule</a> (const cModule *const top)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a pointer to a sub module of the passed module with the type of this template.  <a href="#a661c335281d62d8df4affc46cc4fff9f"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static T&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00093.html#a36e4632a6c8c7dbdc177639957a8e62a">findGlobalModule</a> ()</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a pointer to the module with the type of this template.  <a href="#a36e4632a6c8c7dbdc177639957a8e62a"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top">static cModule *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="a00093.html#af74cf61bdeba8f88de8936dc32fc19ae">findHost</a> (cModule *const m)</td></tr>
<tr><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a pointer to the host module of the passed module.  <a href="#af74cf61bdeba8f88de8936dc32fc19ae"></a><br/></td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="adcb8dec0c1c7e6ea49877517a1da1d7f"></a><!-- doxytag: member="FindModule::findNetwork" ref="adcb8dec0c1c7e6ea49877517a1da1d7f" args="(cModule *const m)" -->
static cModule *&#160;</td><td class="memItemRight" valign="bottom"><b>findNetwork</b> (cModule *const m)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="ab43269ef27c3b79c880a0c490197d556"></a><!-- doxytag: member="FindModule::findHost" ref="ab43269ef27c3b79c880a0c490197d556" args="(const cModule *const m)" -->
static const cModule *&#160;</td><td class="memItemRight" valign="bottom"><b>findHost</b> (const cModule *const m)</td></tr>
<tr><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a8395c1ba92ff155edd95bb470e2ff232"></a><!-- doxytag: member="FindModule::findNetwork" ref="a8395c1ba92ff155edd95bb470e2ff232" args="(const cModule *const m)" -->
static const cModule *&#160;</td><td class="memItemRight" valign="bottom"><b>findNetwork</b> (const cModule *const m)</td></tr>
</table>
<hr/><a name="details" id="details"></a><h2>Detailed Description</h2>
<div class="textblock"><h3>template&lt;typename T = cModule * const&gt;<br/>
class FindModule&lt; T &gt;</h3>

<p>Provides method templates to find omnet modules. </p>
</div><hr/><h2>Member Function Documentation</h2>
<a class="anchor" id="a36e4632a6c8c7dbdc177639957a8e62a"></a><!-- doxytag: member="FindModule::findGlobalModule" ref="a36e4632a6c8c7dbdc177639957a8e62a" args="()" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T  = cModule * const&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">static T <a class="el" href="a00093.html">FindModule</a>&lt; T &gt;::findGlobalModule </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a pointer to the module with the type of this template. </p>
<p>Returns NULL if no module of this type could be found. </p>

<p>References <a class="el" href="a00093.html#a661c335281d62d8df4affc46cc4fff9f">FindModule&lt; T &gt;::findSubModule()</a>.</p>
<div class="fragment"><pre class="fragment">        {
            <span class="keywordflow">return</span> <a class="code" href="a00093.html#a661c335281d62d8df4affc46cc4fff9f" title="Returns a pointer to a sub module of the passed module with the type of this template.">findSubModule</a>(simulation.getSystemModule());
        }
</pre></div>
</div>
</div>
<a class="anchor" id="af74cf61bdeba8f88de8936dc32fc19ae"></a><!-- doxytag: member="FindModule::findHost" ref="af74cf61bdeba8f88de8936dc32fc19ae" args="(cModule *const m)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T  = cModule * const&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">static cModule* <a class="el" href="a00093.html">FindModule</a>&lt; T &gt;::findHost </td>
          <td>(</td>
          <td class="paramtype">cModule *const&#160;</td>
          <td class="paramname"><em>m</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a pointer to the host module of the passed module. </p>
<p>Assumes that every host module is a direct sub module of the simulation. </p>
<div class="fragment"><pre class="fragment">        {
            cModule* parent = m != NULL ? m-&gt;getParentModule() : NULL;
            cModule* node = m;

            <span class="comment">// all nodes should be a sub module of the simulation which has no parent module!!!</span>
            <span class="keywordflow">while</span> (parent != NULL &amp;&amp; parent-&gt;getParentModule() != NULL)
            {
                node = parent;
                parent = node-&gt;getParentModule();
            }
            <span class="keywordflow">return</span> node;
        }
</pre></div>
</div>
</div>
<a class="anchor" id="a661c335281d62d8df4affc46cc4fff9f"></a><!-- doxytag: member="FindModule::findSubModule" ref="a661c335281d62d8df4affc46cc4fff9f" args="(const cModule *const top)" -->
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T  = cModule * const&gt; </div>
      <table class="memname">
        <tr>
          <td class="memname">static T <a class="el" href="a00093.html">FindModule</a>&lt; T &gt;::findSubModule </td>
          <td>(</td>
          <td class="paramtype">const cModule *const&#160;</td>
          <td class="paramname"><em>top</em></td><td>)</td>
          <td><code> [inline, static]</code></td>
        </tr>
      </table>
</div>
<div class="memdoc">

<p>Returns a pointer to a sub module of the passed module with the type of this template. </p>
<p>Returns NULL if no matching submodule could be found. </p>

<p>Referenced by <a class="el" href="a00093.html#a36e4632a6c8c7dbdc177639957a8e62a">FindModule&lt; T &gt;::findGlobalModule()</a>.</p>
<div class="fragment"><pre class="fragment">        {
            <span class="keywordflow">for</span> (cModule::SubmoduleIterator i(top); !i.end(); i++)
            {
                cModule * <span class="keyword">const</span> sub = i();
                <span class="comment">// this allows also a return type of read only pointer: const cModule *const</span>
                T dCastRet = <span class="keyword">dynamic_cast&lt;</span>T<span class="keyword">&gt;</span>(sub);
                <span class="keywordflow">if</span> (dCastRet != NULL)
                    <span class="keywordflow">return</span> dCastRet;
                <span class="comment">// this allows also a return type of read only pointer: const cModule *const</span>
                T recFnd = <a class="code" href="a00093.html#a661c335281d62d8df4affc46cc4fff9f" title="Returns a pointer to a sub module of the passed module with the type of this template.">findSubModule</a>(sub);
                <span class="keywordflow">if</span> (recFnd != NULL)
                    <span class="keywordflow">return</span> recFnd;
            }
            <span class="keywordflow">return</span> NULL;
        }
</pre></div>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>D:/Projects/MiXiM/extsrc/mixim/src/base/utils/<a class="el" href="a00306_source.html">FindModule.h</a></li>
</ul>
</div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="a00093.html">FindModule</a>      </li>

    <li class="footer">Generated on Tue Mar 5 2013 21:26:32 for MiXiM by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.5.1 </li>
   </ul>
 </div>


</body>
</html>
